How can I set up an attibute to only be editable from 2 triggers that I already have? |
Re: Attribute to only be editable from trigger Regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: Attribute to only be editable from trigger Good idea, but I don't think is possible. How do you define a trigger for 2 attributes? Not 2 triggers with the same code. Here is what I tried: string trig_dxl = "Trigger t = current \n AttrDef ad = attrdef t \n ack ad.name \"\" \n Object o = object t o.\"_Change Reason\" = \"test\" " //install on first attribute Trigger t = trigger("test", module->object->attribute->"Object Text", pre, save, 10, trig_dxl) //install on second attribute t = trigger("test", module->object->attribute->"_Change Reason", pre, save, 10, trig_dxl) if(null t) ack "Trigger not installed" else ack "Trigger installed" So, this code installs 2 triggers with the same name. |
Re: Attribute to only be editable from trigger I actually solved this issue. It is possible to install a trigger for all attribute changes. So, in the trigger code I will have to execute different code based on the name of the attribute. Trigger t = trigger("T_Name", module->object->attribute, pre, save, 10, DXL_CODE) this trigger will fire on all attribute changes, so in the DXL_CODE there will be logic to execute based on which attribtue was changed. Something like: Trigger t = current Trigger Module m = module t if(!isVisible m) halt Object o = object t AttrDef ad = attrdef t string atName = ad.name if(atName == "Object Text") { - get reason for change - record reason for change in "_Change Reason" attribtue set trigPreConPass } else if(atName == "_Change Reason") { ack "You cannot change this atttribute manually" set trigPreConFail } And this trigger only executes once and allows changes to any other attribute from within, without firing again. Thank you for stering me in the right direction, Octavian |
Re: Attribute to only be editable from trigger |
Re: Attribute to only be editable from trigger ostanescu - Thu Jul 08 15:02:10 EDT 2010 And this trigger only executes once and allows changes to any other attribute from within, without firing again. Thank you for stering me in the right direction, Octavian Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: Attribute to only be editable from trigger
Don't have time to read all the posts. Had some luck with an almost identical chore.
// pre-save-attr-trigger for 'change Reason'
if (getTriggerState_()) { set(trigPreConFail); halt }
// pre-save-attr-trigger for 'Requirement'
bool TrigState = getTiggerState_()
obj."Change Reason" = "A good reason"
setTriggerState_(TrigState)
string Value = getenv("ProtectChangeReason")
if (null Value) {set(trigPreConFail); halt}
setenv("ProtectChangeReason", "Allow")
obj."Change Reason" = "A good reason"
setenv("ProtectChangeReason", "")
|
Re: Attribute to only be editable from trigger ostanescu - Thu Jul 08 15:02:10 EDT 2010 And this trigger only executes once and allows changes to any other attribute from within, without firing again. Thank you for stering me in the right direction, Octavian
Just an additional proposal: In your set-up, if people have spent some time editing the "Object Text" and only realize after the trigger fires that they forgot to put something in "_Change Reason", then all their work is lost. I am therefore adding a little DB to my trigger code (after setting trigPreConFail), which displays the new attribute value before it is discarded. This at least gives the option to copy / paste the text into a different application in order to save the work for later use, once _Change Reason" is fixed. ... set(trigPreConFail) Buffer attNewValue = create value(trg, attNewValue) DB attributeAccessDB = topMost "Attribute value access rights" DBE infoDBE = text(attributeAccessDB, "", "You can't edit this attribute", 300, 100, true) DBE attrValueDBE = richText( attributeAccessDB, "Proposed new text:", richText(tempStringOf attNewValue), DBE_WIDTH, 100, true) realize attributeAccessDB delete attNewValue show attributeAccessDB ... |
Re: Attribute to only be editable from trigger Thank you the additional solutions. I didn't know there is a trigger state, I will use it next time. For me the best approach is with the single trigger for all attributes, because: 1. there are 2 attributes to be monitorized in the 2 attributes: _Change Reason and _SPR, from which _SRP can be manually edited, but _Change Reason not. 2. also those 2 attributes are going to have some initial default values and the very first change is allowed, only subsequent changes will need a "good reason" to be saved. 3. code stays within one file, and is very similar, in fact I can share it with you, the file is text format. Octavian PS: the .trigger extension is used by a generic script that installs triggers. Attachments attachment_14485302_theTrigger.trigger |